﻿@using Dexter.DataTransferObject
@model Dexter.Web.Mvc.ViewModel.ViewsData.PublicBaseViewData

@{
    Layout = null;
}

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head profile="http://gmpg.org/xfn/11">
		<title>
			@RenderSection( "title", false )
			@if (!IsSectionDefined("title")) { 
				@Model.Title
			}
		</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		@Html.HeadSuperPack()
		<link rel="shortlink" href="http://bit.ly/cq1byP" />

		@{
			Html.AddCss("Site.css");
			Html.AddCss("FancyBox.css");
			Html.AddCss("SyntaxHighlighter/shCore.css");
			Html.AddCss("SyntaxHighlighter/shThemeDefault.css");
		} 

		@Html.RenderCssCombined()
	
		@if (Request.Browser.Browser.ToLower() == "ie" && Request.Browser.MajorVersion < 7)
		{
			<text>
				<style type="text/css" media="screen">
					@@import "@Url.Content("~/Styles/ie6.css")";
				</style>
			</text>
		}

		@*@Html.Raw(Model.Configuration.HeaderCode)*@
		@RenderSection("head", false)

	</head>
	<body class="home">
		<div id="page-wrap1">
				<div id="page-wrap2">
					<div id="page" style="width:95%" class="with-sidebar">
						<div id="main-wrap">
							<div id="mid-wrap">
								<div id="side-wrap">
									<div id="mid">
										<div id="header">
											<div id="topnav">
												<h1>@Model.KeyWords</h1>
											</div>
											<a id="logo" href="@Html.Raw(U.HomePage.ToString())" title="Home Page" rel="Home">
												@if(Request.Browser.Browser.ToLower() == "ie" && Request.Browser.MajorVersion < 7)
												{
													<img alt="@Model.Description" title="@Model.Description" src="@Url.Content("~/Images/Logos/logoie6.png")" />
												}
												else
												{
													<img alt="@Model.Description" title="@Model.Description" src="@Url.Content("~/Images/Logos/logo.png")" />
												}
											</a>
											<a id="mvp" href="https://mvp.support.microsoft.com/profile=BA42056F-DDC9-4762-8F9C-6FFFF392D9F9" rel="nofollow" target="_blank" style="margin-left:400px;" width="100" height="40">
												<img alt="MVP Profile" src="@Url.Content("~/Images/Logos/mvp.png")" />
											</a>
											@Menu()
										</div>
										<div id="mid-content">
											@RenderBody()
										</div>
									</div>
									<div id="sidebar">
										<div id="sidebar-wrap1">
											<div id="sidebar-wrap2">
												<ul>
													<li>
														<div id="searchtab">
															<div class="inside">
																<form id="searchForm" action="@U.SearchHome" method="get" defaultbutton="searchButton" defaultfocus="q">
																	<input id="q" name="q" maxlength="40" class="searchfield" type="text" value="Search" />
																	<input id="searchButton" name="searchButton" class="searchbutton" type="submit" value="Go" />
																</form>
															</div>
														</div>
													</li>
													@if (Request.Url.Segments.Contains("Search") && !string.IsNullOrEmpty(Request.QueryString["q"]))
													{
														<li class="infotext">
															<p class="error">You have searched the archives for <strong>@Request.QueryString["q"]</strong>.</p>
														</li>
													}
													@Html.Partial("_sidebar")
												</ul>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="clearcontent" />
						@Html.Partial( "_footer" )
					</div>
				</div>
		</div>
		<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
		<script type="text/javascript">window.jQuery || document.write('<script src="js/libs/jquery-1.7.1.min.js"><\/script>')</script>
		<script src="@Url.Content("~/scripts/effects.js")" type="text/javascript" language="javascript"></script>
		@{
			Html.AddJs("jquery.lazyload.mini.js");
			Html.AddJs("jquery.watermark.js");
			Html.AddJs("jquery.cookie.js");
			Html.AddJs("jquery.highlight-1.1.js");
			Html.AddJs("CodeHighlither/shCore.js");
			Html.AddJs("CodeHighlither/shBrushCSharp.js");
			Html.AddJs("CodeHighlither/shBrushXml.js");
			Html.AddJs("CodeHighlither/shBrushSql.js");
			Html.AddJs("jquery.validate.min.js");
			Html.AddJs("MicrosoftMvcJQueryValidation.js");
		}
	
		@Html.RenderJsCombined()
		@RenderSection("footer", false)
		@Html.Raw(Model.Configuration.FooterCode)
	</body>
</html>


@helper Menu(){
	<text>
		<div id="tabs">
			<ul>
				@for (int i = 0; i < Model.Pages.Count; i++)
				{
					var page = Model.Pages[i];
					if(page.IsPublished)
					{
						@CorrectLiControl(page,i)
						@MenuItem(page)
						if(page.Pages != null && page.Pages.Any())
						{
							<ul>
								@foreach (var subPage in page.SortedPages)
								{
									@MenuItem(subPage)
								}
							</ul>
						}
						@Html.Raw("</li>")
					}
				}
			</ul>
		</div>
	</text>	
}

@helper CorrectLiControl(PageStructureDto page, int pageIndex)
{
	var currentUrlRequested = Context.Request.Url;

	if (currentUrlRequested.Segments.Length == 1 && pageIndex == 0)
	{
		<text>
			<li class="current_page_item">
		</text>
	}
	else if (currentUrlRequested.Segments.Length > 1)
	{
		if (currentUrlRequested.Segments[1].ToLower().Replace("/", string.Empty) == page.Title.ToLower())
		{
			<text><li class="current_page_item"></text>
		}
		else
		{
			<text><li class="page_item"></text>
		}
	}
	else
	{
		<text><li class="page_item"></text>
	}
}
@helper MenuItem(PageStructureDto page)
{
	<a title="@page.Title" href="@Html.Raw(U.Page.Detail(page))">
		<span><span>@page.Title</span></span>
	</a>
}